<?php
/**
 * @purpose: 对“通知”类型中子类型为9(某人加你为好友后，你将收到一个通知)的编码与解码文件
 * @author: Mandel Woo <wuzhijian@snda.com>

 * @memo: 参阅母板
 */
require_once(dirname(__FILE__)."/../../../models/user/UCModUserInfo.php");


function msg_notice_type9_encoder() {
	$fields = array("usr_id");

	foreach($fields as $k => $v) {
		eval("\${$v}=func_get_arg($k);");
	}

	return serialize(array(
			"usr_id" => $usr_id,
			));
}

function msg_notice_type9_decoder() {
	#这里不改动, begins
	$fields = array("id","receiverid","content","createTime","changeFlag","fmt");
	foreach($fields as $k => $v) {
		eval("\${$v}=func_get_arg($k);");
	}
	#这里不改动, ends


	$data   = unserialize($content);
	$usr_id = $data['usr_id'];

	$user_info = UCModUserInfo::getUserInfo($usr_id, array(USERINFO_NICKNAME,USERINFO_GENDER));
	$nickname  = $user_info[USERINFO_NICKNAME];
	$nickname  == '' && $nickname = $usr_id; #取不到昵称
	$gender    = $user_info[USERINFO_GENDER] == 1 ? "他" : "她";

	$usr = "<a href=\"".get_user_home_url($usr_id)."\" target='_blank'>{$nickname}</a>";


	#!!!输出处将不做html转义，须保证用户输入数据的安全
	if ($fmt == 'line') {
		return sprintf("%s加你为好友，赶快去看看%s吧", $usr, $gender);

	} else if ($fmt == 'box') {
		$html = sprintf("%s加你为好友，赶快去看看%s吧！", $usr, $gender);
		return '<div class="font14">' . $html . '</div>';

	} else {
		return '';
	}
}


